//
//  BodiUIview.m
//  UI05_rainbowLamp
//
//  Created by Bodi on 16/6/12.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "BodiUIview.h"
#import "BodiUILabel.h"
@implementation BodiUIview

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame withCount:(NSInteger)count{

    self = [super initWithFrame:frame];
    if (self) {
        for (int i = 0; i < count ; i++) {
//
            
            
            BodiUILabel *label = [[BodiUILabel alloc]initWithFrame:CGRectMake(15 * i, 15 * i, self.frame.size.width - (30 * i), self.frame.size.height - (30 * i))];
            label.tag = 100 + (i * 1);
            
            [self addSubview:label];

        }
        _count = count;
        [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeColor:) userInfo:nil repeats:YES];
    }
    return self;

}
- (void)changeColor:(NSTimer *)time{
    UIColor *temp = [self viewWithTag:100].backgroundColor;
       for (int i = 0; i < _count; i++) {
        
        [self viewWithTag:100 + i].backgroundColor = [self viewWithTag:101 + i].backgroundColor;
        
    }
    [self viewWithTag:106].backgroundColor = temp;
}

@end
